package top.zhangjianyong.blog.portal.controller;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.blog.response.ApiResponse;
import top.zhangjianyong.blog.service.FileService;

/**
 * @author zhangjianyong
 * @since 2024/8/18 下午2:36
 */
@RequestMapping("/portal/file")
@RestController("portalFileController")
public class FileController {

    private final FileService fileService;

    public FileController(FileService fileService) {
        this.fileService = fileService;
    }

    @GetMapping("/{id}")
    public ApiResponse get(@PathVariable("id") Long id,
                           HttpServletResponse response) {

        // 防盗链验证已由AntiHotlinkFilter统一处理
        return fileService.get(id, response);
    }
}
